﻿using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Xml.Linq;

namespace SharePointUtilitiesForDevelopers
{
    /// <summary>
    /// A domain class that represents a SharePoint Web.
    /// </summary>
    [ReadOnly(true)]
    [DefaultProperty("Title")]
    public class SharePointWeb
    {
        /// <summary>
        /// Gets or sets the title.
        /// </summary>
        /// <value>The title.</value>
        [Description("The web title.")]
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets the URL.
        /// </summary>
        /// <value>The URL.</value>
        [Description("The web url.")]
        public string Url { get; set; }

        /// <summary>
        /// Gets or sets the site columns.
        /// </summary>
        /// <value>The site columns.</value>
        [Description("The site columns in the web.")]
        public ReadOnlyCollection<SharePointField> SiteColumns { get; set; }

        /// <summary>
        /// Gets or sets the lists.
        /// </summary>
        /// <value>The lists.</value>
        [Description("The lists in the web.")]
        public ReadOnlyCollection<SharePointList> Lists { get; set; }

        /// <summary>
        /// Gets or sets the content types.
        /// </summary>
        /// <value>The content types.</value>
        [Description("The content types in the web.")]
        public ReadOnlyCollection<SharePointContentType> ContentTypes { get; set; }

        /// <summary>
        /// Gets or sets the definition.
        /// </summary>
        /// <value>The definition.</value>
        [Description("The XML definition for the web.")]
        public XElement Definition { get; set; }

        /// <summary>
        /// Gets or sets the id of the list that contains site user information.
        /// </summary>
        /// <value>The id of the list that contains site user information.</value>
        [Description("The list in the web that contains user information.")]
        public SharePointList SiteUserInfoList { get; set; }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            return string.Format("{0} ({1}", Title, Url);
        }
    }
}